<template lang="pug">
    skin(@yes="yes",@back="back")
        div(class="flex-column charge-exhaust-reset h3")
            div(class="flex-column-item ")
            div(class="flex-column-item")
                div(class="center") {{ reseted ? '复位完成！': '螺杆复位中...' }}
                div(class="center")   {{reseted ? '请装入储药器' :amount}}  
            div(class="flex-column-item")
</template>

<script>
    export default {
        data() {
            return {
                activeId: 0,
                page: {maxResultCount: 3, skipCount: 0},
                visible: false,
                amount: 19.6,
                reseted: false, // 复位完成
                interval: null
            };
        },
        computed: {},
        methods: {
            back() {
                window.excharge.resetRecords.push({reset_at: new Date()});
                this.$router.push('index?index=0');
            },
            yes() {
                window.excharge.resetRecords.push({reset_at: new Date()});
                if (this.reseted) this.$router.push('exhaust2?index=0');
            }
        },
        mounted() {
            this.interval = setInterval(function () {
                const total = window.dose.totalAmount;
                if (window.dose.remainingAmount < total) {
                    const cal = (window.dose.remainingAmount * 10 + 2.8 * 10) / 10;
                    window.dose.remainingAmount = cal > total ? total : cal;
                } else {
                    this.reseted = true;
                    clearInterval(this.interval);
                }
                this.amount = window.dose.remainingAmount;
            }.bind(this), 300);
        }
    };
</script>

<style lang="less">

</style>
